/**
 * losenote.com Inc.
 * Copyright (c) 2013-2013 All Rights Reserved.
 */
package com.losenote.model.ct;

import com.losenote.enums.DataStateEnum;
import com.losenote.model.AttachFile;
import com.losenote.model.CategoryItem;
import com.losenote.orm.CategoryItemDO;

/**
 * 
 * @author danjingyu
 * @version $Id: CategoryItemConvertor.java, v 0.1 2013-9-12 下午8:27:34 danjingyu Exp $
 */
public class CategoryItemConvertor {

    /**
     * 将do转换成领域对象
     * 
     * @return
     */
    public static CategoryItem fromDo(CategoryItemDO categoryItemDO, AttachFile attachFile) {
        CategoryItem categoryItem = new CategoryItem();
        categoryItem.setAttachImg(attachFile);
        categoryItem.setCreator(categoryItemDO.getCreator());
        categoryItem.setDescription(categoryItemDO.getDescription());
        categoryItem.setFatherId(categoryItemDO.getFatherId());
        categoryItem.setGmtCreate(categoryItemDO.getGmtCreate());
        categoryItem.setGmtModified(categoryItemDO.getGmtModified());
        categoryItem.setId(categoryItemDO.getId());
        categoryItem.setLastModifier(categoryItemDO.getLastModifier());
        categoryItem.setName(categoryItemDO.getName());
        categoryItem.setState(DataStateEnum.getByValue(categoryItemDO.getState()));
        return categoryItem;
    }
}
